home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1137 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.7 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: jsberg@hpslap03.cern.ch (J. Scott Berg)
  3. Newsgroups: comp.std.c++
  4. Subject: Initialization of nonlocal objects with static storage duration
  5. Date: 17 Apr 1996 10:41:38 PDT
  6. Organization: CERN, European Laboratory for Particle Physics
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <Dq0071.23J@news.cern.ch>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: Wed, 17 Apr 1996 08:42:37 GMT
  11. Apparently-To: comp-std-c++@dxnews.cern.ch
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMXUtU0y4NqrwXLNJAQHBOgH/TCelQMW+4x1FI4++SFPQpILw4WdQ0amY
  14.     f9S+sRXhDbaQNBPqOrEe/aBe0PC55s1CvwHj1VhO9fgOsSuK1r/Txg==
  15.     =BFJk
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. If one looks at section 3.6.2 of the April WP, one finds the rules
  19. given there for initialization of non-local objects with static
  20. storage duration to be the following:
  21.  
  22. 1) They are initialized before the first use of any function or object
  23. defined in that translation unit.
  24. 2) The storage is zero-initialized before any other initialization
  25. takes place.
  26. 3) Objects with static storage duration initialized with constant
  27. expressions are initialized before any other initialization takes
  28. place.
  29. 4) The order of initialization of nonlocal objects with static storage
  30. duration defined in the same translation unit is the order in which
  31. their definition appears in the translation unit.
  32.  
  33. I was told that 1) no longer appears in the draft, since it could
  34. become circular, among other things.  What of this, if any, can I
  35. reasonably rely on existing in the final standard?
  36.  
  37. My reason is that I wish to have classes defined in different
  38. translation units which register themselves with another class via an
  39. initialization of a global object.  The class with which they register
  40. themselves keeps the list in a static member, which must be
  41. initialized before any of the other classes register themselves.  I
  42. had attempted to do this using 1), and when that didn't work, I
  43. reported it as a bug and was told that 1) was no longer part of the
  44. standard.  If I could rely on 2), for instance, I could make a global
  45. pointer to the list and check if it was null, for instance,
  46. initializing the list if it was; 3) would work similarly.
  47.  
  48. Thank you very much
  49.  
  50.                 -Scott Berg
  51.  
  52. -- 
  53. J. Scott Berg                      email: Scott.Berg@cern.ch
  54. Work Phone: (41-22-)767-94-67      Real mail: CERN; SL Division; Bldg 30-2002
  55. Home Phone: (41-22-)783-03-15                 CH-1211 Geneva 23; Switzerland
  56. ---
  57. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  58.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  59.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  60.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  61.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  62. ]
  63.